<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

setlocale(LC_ALL, 'zh_CN.UTF-8');

require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');


//根据端口号访问不同目录
$port_dir = [
    '80'   => 'admin',//超级后台
];

if(!isset($port_dir[$_SERVER['SERVER_PORT']]))
    exit;
define('CONFIG_SUFFIX', $port_dir[$_SERVER['SERVER_PORT']]);
ini_set('session.name', 'PHPSESSID_' . strtoupper(CONFIG_SUFFIX));//用来将SESSION独立开

$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/../../common/config/main.php'),
    require(__DIR__ . '/../../common/config/main-local.php'),
    require(__DIR__ . '/../config/main.php'),
    require(__DIR__ . '/../config/main-'.CONFIG_SUFFIX.'.php')
);

$application = new yii\web\Application($config);
$application->run();
